class Light {
    status: string
    color: string
}

function open(light: Light) {
    if (light.status === "on") {
        throw new Error("The light is on")
    }
    light.status = "on"
}

function setColor(light: Light, color: string) {
    if (light.status !== "on") {
        throw new Error("The light is not on")
    }
    light.color = color
}

function main() {
    const light = new Light()
    open(light)
    setColor(light, "red")
}
